﻿Imports System.Data.OleDb

Public Class About
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Public Sub upload(ByVal sender As Object, ByVal e As EventArgs) Handles btn_upload.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("photodb").ConnectionString)
        Dim sql = "INSERT INTO gallery (name,imagelocation,caption,catID,collection) VALUES (@f1,@f2,@f3,@f4,@f5)"
        Dim cmd = New OleDbCommand(sql, conn)

        If (tb_img_loc.HasFile) Then
            tb_img_loc.SaveAs(Request.MapPath("pictures") & "/" & tb_cat.SelectedItem.Text & "/" & tb_img_loc.FileName)
        End If
        conn.Open()
        'cmd.Parameters.AddWithValue("@f1", tb_name.Text)
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", "pictures/" & tb_cat.SelectedItem.Text & "/" & tb_img_loc.FileName)
        cmd.Parameters.AddWithValue("@f3", tb_caption.Text)
        cmd.Parameters.AddWithValue("@f4", tb_cat.SelectedValue)
        cmd.Parameters.AddWithValue("@f5", RadioButtonList1.SelectedValue.ToString())
        Session("N") = User.Identity.Name
        cmd.ExecuteNonQuery()

        conn.Close()
        Response.Redirect("confirmation.aspx")
    End Sub

End Class